import Vue from 'vue'
import Vuex from 'vuex'
import localDb from '../utils/localDb'
import frontPage from "./modules/frontPage";

Vue.use(Vuex)

export default new Vuex.Store({
  state: {
    token: localDb.get('TOKEN'),  //设置token
    user: localDb.get('user'), //用户名
    stuList: localDb.get('stuList'),   //学生信息表
    verify: localDb.get('verify'),     //验证是否可以修改及提交报名信息
    wpzswTitle: localDb.get('wpzswTitle'),  //页头标题
    isDelayApply: localDb.get('delayApply'), //是否延缓入学
    emptyEnter: localDb.get('emptyEnter'), //是否开始报名
  },
  mutations: {
    SETTOKEN(state, payLoad) {
      localDb.set('TOKEN', payLoad)
      state.token = localDb.get('TOKEN');
    },
    SETUSER(state, payLoad) {
      localDb.set('user', payLoad)
      state.user = localDb.get('user');
    },
    SETSTULIST(state, payLoad) {
      localDb.set('stuList', payLoad)
      state.stuList = localDb.get('stuList');
    },
    SETSTVERIFYT(state, payLoad) {
      localDb.set('verify', payLoad)
      state.verify = localDb.get('verify');
    },
    SETWPZSWTITLE(state, payLoad) {
      localDb.set('wpzswTitle', payLoad)
      state.wpzswTitle = localDb.get('wpzswTitle');
    },
    SETDELAYAPPLY(state, payLoad) {
      localDb.set('delayApply', payLoad)
      state.isDelayApply = localDb.get('delayApply')
    },
    SETEMPTYENTER(state, payLoad) {
      localDb.set('emptyEnter', payLoad)
      state.emptyEnter = localDb.get('emptyEnter');
    }
  },
  actions: {
    setToken(context, payload) {
      context.commit('SETTOKEN', payload);
    },
    setUser(context, payload) {
      context.commit('SETUSER', payload);
    },
    setStuList(context, payload) {
      context.commit('SETSTULIST', payload);
    },
    setVerify(context, payload) {
      context.commit('SETSTVERIFYT', payload);
    },
    setWpzswTitle(context, payload) {
      context.commit('SETWPZSWTITLE', payload);
    },
    setEmptyEnter(context, payload) {
      context.commit('emptyEnter', payload)
    }
  },
  modules: {
    frontPage,
  }
});
